/**
 * 
 */
package core.modules;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;

/**
 * @author Glenn Mark
 *
 */
public class ProjectUtilities {

	public static String toSQLDate(int MM, int dd, int yyyy)  throws NullPointerException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
		String stringDate = Integer.toString(MM) + "/" + Integer.toString(dd) + "/" + Integer.toString(yyyy);
		try {
			 return sdf.format(new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH).parse(stringDate));
			
		} catch (ParseException e) {
			System.err.println("[ERROR] ParseException " + stringDate);
		}
		return null;
	}
	
	
	public static String toStringDate(String sqlDate) throws NullPointerException {
		
		SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
		
		try {
			 return sdf.format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(sqlDate));
			
		} catch (ParseException e) {
			System.err.println("[ERROR] ParseException " + sqlDate);
		}
		return null;
	}
	
	
}
